package com.zt.bigdata.vertx.interceptor

import com.ecfront.dew.common.Resp
import com.typesafe.scalalogging.LazyLogging
import io.vertx.ext.web.RoutingContext
import org.springframework.stereotype.Service

import scala.concurrent.Promise

/**
  *
  */
@Service
class BFilter[E <: Animal, R <: Object] extends HttpAsyncFilter[E, R] with LazyLogging {
  override def before(routingContext: RoutingContext, animal: E, future: Promise[Resp[R]]): Unit = {
    logger.info("BFilter Before")
    animal.speak()
    future.success(Resp.success("ok".asInstanceOf[R]))
  }

  override def after(routingContext: RoutingContext, animal: E, future: Promise[Resp[R]]): Unit = {
    logger.info("BFilter After")
    animal.speak()
    future.success(Resp.success("ok".asInstanceOf[R]))
  }
}
